import javax.jws.WebService;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/hello")
public class HelloServet extends HttpServlet {
    @Override
    public void init() throws ServletException {
             //super.init();  注释掉
        System.out.println("执行 init");
    }

    @Override
   protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
        response.setContentType("text/html; charset=utf-8");
       System.out.println("hello word1");//这是在服务器的控制台中打印了字符串(服务器能看到,客户端看不到)
       response.getWriter().write("hello word2 响应"); //这是给response的body中写入hello Word字符串这个内容会被HTTP响应返回给浏览器,显示到浏览器的页面上
   }
}
